//
//  UserView.m
//  Custom_Weibo
//
//  Created by LEO on 12/15/15.
//  Copyright © 2015 Leo_Lei. All rights reserved.
//

#import "UserView.h"

@implementation UserView

- (void)setWeiboModel:(WeiboModel *)weiboModel {
    if (_weiboModel != weiboModel) {
        _weiboModel = weiboModel;
        [self setNeedsLayout];
    }
}

- (void)awakeFromNib {
    [self setNeedsLayout];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    //  Make the user image shape into circle.
    _userImage.layer.cornerRadius = _userImage.width / 2;
    _userImage.layer.masksToBounds = YES;
    
    
    //  Download the image, and add it on the image view.
    NSString *imageURL = _weiboModel.userModel.avatar_large;
    [_userImage sd_setImageWithURL:[NSURL URLWithString:imageURL]];
    
    //  Set user name.
    _userName.text = _weiboModel.userModel.screen_name;
    
    _sourceLabel.text = _weiboModel.source;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
